
//城市二联
var citytoN = function(sId, classIs,is,cityName) {
	$.ajax({
		type : "get",
		dataType : "json",
		url : "/selevtBysIdToCitys",
		data : {
			"sId" : sId
		},
		async : true,
		success : function(data) {
			if(is>0){
				for (var i = 0; i < data.length; i++) {
					if(data[i].cityName==cityName){
						$(classIs).append(
								"<option selected='selected'  value=" + data[i].cityName + ">"
										+ data[i].cityName + "</option>")
					}else{
						$(classIs).append(
								"<option  value=" + data[i].cityName + ">"
										+ data[i].cityName + "</option>")
					}
				}
			}else{
				for (var i = 0; i < data.length; i++) {
					$(classIs).append(
							"<option  value=" + data[i].cityName + ">"
									+ data[i].cityName + "</option>")
				}
			}
			
		}
	})
}
//日期天数
function dateDiff(interval, date1, date2) {
	var objInterval = {
		'D' : 1000 * 60 * 60 * 24,
		'H' : 1000 * 60 * 60,
		'M' : 1000 * 60,
		'S' : 1000,
		'T' : 1
	};
	interval = interval.toUpperCase();
	var dt1 = Date.parse(date1.replace(/-/g, '/'));
	var dt2 = Date.parse(date2.replace(/-/g, '/'));
	try {
		return Math.round((dt2 - dt1) / eval('(objInterval.' + interval + ')'));
	} catch (e) {
		return e.message;
	}
}

function judge(name,msg){
	if(name==""||name==null){
		layer.msg(msg,{time:1500,})
		return true;
	}
}
//型号类型
var carTypeFn = function(carBrandId, classIs,is,carModelId){
	$.ajax({
		type : "get",
		dataType : "json",
		url : "/carType/selByBrandId",
		data : {"carBrandId" : carBrandId},
		async : true,
		success : function(data) {
			if(is>0){
				for (var i = 0; i < data.length; i++) {
					if(data[i].carTypeId==carModelId){
						$(classIs).append(
								"<option selected='selected'  value="+data[i].carTypeId+">"
									+ data[i].carTypeName
								+ "</option>")
					}else{
						$(classIs).append(
								"<option   value="+data[i].carTypeId+">"
							+ data[i].carTypeName
						+ "</option>")
					}	
				}
			}else{
				for (var i = 0; i < data.length; i++) {
				$(classIs).append(
					"<option   value="+data[i].carTypeId+">"
					+ data[i].carTypeName
					+ "</option>")
			}
			}
			
		}
	})
}

//日期转换
var myFunction=  function (dates){
	        var dateee = new Date(dates).toJSON();
	        var date = new Date(+new Date(dateee)+8*3600*1000).toISOString().replace(/T/g,' ').replace(/\.[\d]{3}Z/,'')  
	        return date;

	}

var appendTotr = function(url,data,siblingsRemoveClass,appendClass){
	$.ajax({
		url:url,
		type:"get",
		dataType:"json",
		data:data,
		async:true,
		success: function(data){
			$(siblingsRemoveClass).siblings("tr").remove();
			$("#xiao").remove();
			if(data.msg){
				for (var i = 0; i < data.list.length; i++) {
					$(appendClass).append(
							'<tr><td>'+data.list[i].orderId+'</td><td>'+myFunction(data.list[i].actualVehicleTakingTime)+'</td><td>'+myFunction(data.list[i].actualTransferTime)+'</td><td>'+data.list[i].theCarStores+'</td><td>'+data.list[i].theDoorPoint+'</td><td>'+data.list[i].takeCarcity+'</td><td>'+data.list[i].carCity+'</td><td>'+data.list[i].limitTheTotalMileage+'</td></tr>')
				}
			}else{
				$(appendClass).append('<img id="xiao" style="display:inline-block; position:absolute; margin-left:30%" src="/img/no_points.png">')
			}
			
			
			
		}
	})
	
}



